<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\goods\model;

use think\Model;

class GoodsTypeModel extends Model
{

    public function getTypeList()
    {
        $where = ['t.site_id' => get_site_id()];
        $list = $this
             -> alias('t')
             -> field('t.*, COUNT(a.cat_id) AS attr_count ')
             -> join('__GOODS_ATTRIBUTE__ a', 'a.cat_id=t.cat_id','LEFT')
             -> where($where)
             -> group('t.cat_id')
             -> paginate(20);

        return $list;
    }

}
